<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;

class Referee extends Model
{
    use HasFactory;

    protected $fillable = [
        'name', 'phone', 'province', 'city', 'dealer_id', 'interest', 'point_total'
    ];

    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function scopeDealerCode($query, $dealer_code)
    {
        $dealer = Dealer::where('code', $dealer_code)->first();
        return $query->where('dealer_id', $dealer->id);
    }
}
